package mygame;

import character.AbstractCharacter;
import com.jme3.renderer.Camera;
import gameobject.construct.Construct;

/** Represents the abstract concept of a player, storing data related to them. */
public class Player {
    protected Camera camera;
    protected AbstractCharacter selectedCharacter;
    protected Construct selectedConstruct;
    protected String selectedAction;
    /** Basically an uninstantiated AbstractConstruct, this is the AbstractConstruct the player is currently placing in the world. */
    protected Construct placer;
    
    public Player() {}
    
    public Player(Camera camera) {
        this.camera = camera;
    }

    public Camera getCamera() {
        return camera;
    }

    public void setCamera(Camera camera) {
        this.camera = camera;
    }

    public AbstractCharacter getSelectedCharacter() {
        return selectedCharacter;
    }

    public void setSelectedCharacter(AbstractCharacter selected) {
        this.selectedCharacter = selected;
	clearSelectedConstruct();
    }

    public boolean hasSelectedCharacter() {
	return selectedCharacter != null;
    }
    
    public void clearSelectedCharacter() {
        this.selectedCharacter = null;
    }

    public Construct getSelectedConstruct() {
        return selectedConstruct;
    }

    public void setSelectedConstruct(Construct selected) {
        this.selectedConstruct = selected;
	clearSelectedCharacter();
    }

    public boolean hasSelectedConstruct() {
	return selectedConstruct != null;
    }

    public void clearSelectedConstruct() {
        this.selectedConstruct = null;
    }

    public String getSelectedAction() {
	return selectedAction;
    }

    public void setSelectedAction(String currentAction) {
	this.selectedAction = currentAction;
    }

    public void toggleSelectedAction(String currentAction) {
	if(this.selectedAction != null && this.selectedAction.equals(currentAction))
	    clearSelectedAction();
	else
	    setSelectedAction(currentAction);
    }

    public boolean hasSelectedAction() {
	return selectedAction != null;
    }

    public void clearSelectedAction() {
	setSelectedAction(null);
    }

    public Construct getPlacer() {
	return placer;
    }

    public void setPlacer(Construct placer) {
	this.placer = placer;
    }

    public boolean hasPlacer() {
	return placer != null;
    }

    public void clearPlacer() {
	setPlacer(null);
    }
}
